def print_table(data, headers, alignment='left'):
    """
    打印格式化表格

    :param data: 二维列表数据 [[row1], [row2], ...]
    :param headers: 表头列表 ["列1", "列2", ...]
    :param alignment: 对齐方式 ('left', 'center', 'right')
    """
    # 转换所有数据为字符串
    str_data = [[str(item) for item in row] for row in data]
    str_headers = [str(h) for h in headers]

    # 计算各列最大宽度
    col_widths = [
        max(len(str_row[i]) for str_row in [str_headers] + str_data)
        for i in range(len(headers))
    ]

    # 生成分隔线
    separator = "+" + "+".join(["-" * (w + 2) for w in col_widths]) + "+"

    # 定义对齐函数
    align_map = {
        'left': str.ljust,
        'right': str.rjust,
        'center': str.center
    }
    align_func = align_map[alignment]

    # 打印表头
    print(separator)
    header_cells = [
        align_func(header, width).upper()
        for header, width in zip(str_headers, col_widths)
    ]
    print("| " + " | ".join(header_cells) + " |")
    print(separator.replace('-', '='))

    # 打印数据行
    for row in str_data:
        cells = [
            align_func(cell, width)
            for cell, width in zip(row, col_widths)
        ]
        print("| " + " | ".join(cells) + " |")

    print(separator)


if __name__ == '__main__':

    # 使用示例
    t_data = [
        ["Alice", 24, "Engineer", 85.5],
        ["Bob", 30, "UI Designer", 92.0],
        ["Charlie", 28, "Python Developer", 88.9]
    ]

    t_headers = ["Name", "Age", "Occupation", "Score"]
    print_table(t_data, t_headers, alignment='center')